<?php
/*
 * 测试原型模式
 */

namespace App\Controller;

use App\DesignPattern\Prototype\Prototype;

class ControllerPrototype {

	public function actionIndex()
    {
        $prototype = new Prototype();
        $prototype->init();

        $obj1 = clone $prototype;
        echo "{$obj1->getCode()}<br/>";
        $obj1->setCode(110);

        $obj2 = clone $prototype;
        echo '$obj1和$obj2除了使用了相同的原型，其他都是独立的<br/>';
        echo "{$obj2->getCode()}<br/>";
	}
}
